home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / network / exp16116.zip / DIGOUT.ASM < prev    next >
Assembly Source File  |  1992-08-05  |  615b  |  34 lines

  1. ;put into the public domain by Russell Nelson, nelson@crynwr.com
  2.  
  3.     public    dwordout, wordout, byteout, digout
  4. dwordout:
  5.     mov    cl,'0'            ;prepare to eliminate leading zeroes.
  6.     xchg    ax,dx            ;just output 32 bits in hex.
  7.     call    wordout            ;output dx.
  8.     xchg    ax,dx
  9. wordout:
  10.     push    ax
  11.     mov    al,ah
  12.     call    byteout
  13.     pop    ax
  14. byteout:
  15.     mov    ah,al
  16.     shr    al,1
  17.     shr    al,1
  18.     shr    al,1
  19.     shr    al,1
  20.     call    digout
  21.     mov    al,ah
  22. digout:
  23.     and    al,0fh
  24.     add    al,90h    ;binary digit to ascii hex digit.
  25.     daa
  26.     adc    al,40h
  27.     daa
  28.     cmp    al,cl            ;leading zero?
  29.     je    digout_1
  30.     mov    cl,-1            ;no more leading zeros.
  31.     jmp    chrout
  32. digout_1:
  33.     ret
  34.